<?php

    // +----------------------------------------------------------------------
    // | 访问记录
    // +----------------------------------------------------------------------
    // | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
    // +----------------------------------------------------------------------
    // | Author: 微尘 <yicmf@qq.com>
    // +----------------------------------------------------------------------
    
    namespace app\model\ucenter;

    class VisitLog extends Common
    {


		/**
		 * 写入修改
		 * @param $data
		 */
		public static function onBeforeInsert($data)
		{
			$data['status'] = 1;
			$data['param'] = '';
			$data['os'] = '';
			$data['url'] = '';
			$data['ip'] = request()->ip();
		}


        protected function setOsAttr()
        {
            if ('cli' != PHP_SAPI) {
                return $this->request->server('HTTP_USER_AGENT');
            } else {
                return 'cli';
            }
        }

        protected function setParamAttr()
        {
            if ('cli' != PHP_SAPI) {
                $param = $this->request->param();
                foreach ($param as $key => &$value) {
                    if ('password' == $key) {
                        $value = '******';
                    }
                }
                return var_export($param, true);
            } else {
                return 'cli';
            }
        }

        protected function setUrlAttr()
        {
            return $this->request->url(true);
        }
    }
